  <?php
  require_once('../practice/includes/db.php');

  unset($_POST['submit']);
  if($_FILES['avatar']['error'] == 0){
    $return = avatar_upload($_FILES,$_POST['current_avatar']);
    if($return['flag']==1){
      $_POST['avatar'] = $return['name'];
    }
  }
  unset($_POST['current_avatar']);

  $where = "WHERE `id`= $_POST[id]";
  $affected_rows = update('user_images',$_POST,$where);

  setMessage( success("Avatar Updated :: $affected_rows"));

 header('location:index.php');
